// pages/goDutch/childCpns/group-users/group-users.js
import {request, requestHasToken} from '../../../../service/network'
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    users: {
      type: Array,
      value: []
    },
    state: {
      type: String,
      value: '报名中'
    },
    createrUserOpenidBoolean: {
      type: Boolean,
      value: false
    },

  },

  /**
   * 组件的初始数据
   */
  data: {
    state: ''
  },

  /**
   * 组件的方法列表
   */
  methods: {
    handleDel(e) {
      console.log(e);
      const id = e.currentTarget.dataset.id
      const gname = e.currentTarget.dataset.gname
      wx.showModal({
        title: '提示',
        content: '确认删除'+gname+' 的报名吗?',
        success: (res) => {
          if (res.confirm) {
            requestHasToken({
              url: 'api/go/dutchUser/remove',
              data: {
                id: id,
              }
            }).then((res) => {
              wx.showToast({
                title: '删除成功!',
                icon: 'success',
                duration: 1000
              })
              this.triggerEvent('usersDel', {id}, {})
            })
          } else if (res.cancel) {}
        }
      })
    },
  },
  lifetimes: {
    created() {
      // console.log('组件被创建出来时');
      this.setData({
        state: this.properties.state,
        createrUserOpenidBoolean: this.properties.createrUserOpenidBoolean
      })
    },
  }
})
